//
//  HomeModel.m
//  ChunLaiZhuangClient
//
//  Created by zzs on 16/4/8.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "HomeModel.h"


@implementation HomeModel
-(void)formatData:(KXJson*)modulesJson{
    if (!_modulesArray) {
        _modulesArray=[[NSMutableArray alloc] init];
    }
    for (int i=0; i<modulesJson.count; i++) {
        KXJson *moduleJson=[modulesJson getJsonForIndex:i];
        NSString *type=[moduleJson getStringForKey:@"module_type"];
        if ([type isEqualToString:@"image-carousel"]) {
            Image_carouselModel *model=[[Image_carouselModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"link-icon"]){
            Link_iconModel *model=[[Link_iconModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"product-list"]){
            CommendModel *commendModel=[[CommendModel alloc] init];
            [_modulesArray addObject:commendModel];
            Product_listModel *model=[[Product_listModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"image-banner"]){
            Image_bannerModel *model=[[Image_bannerModel alloc] initWithDictionary:moduleJson.json];
            if ([model.module_show_title intValue]==1) {
                BannerTitleModel *titleModel=[[BannerTitleModel alloc] init];
                titleModel.title=model.module_name;
                [_modulesArray addObject:titleModel];
            }
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"images-two-average"]){
            Images_two_averageModel *model=[[Images_two_averageModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"images-three-left-one"]){
            Images_three_left_oneModel *model=[[Images_three_left_oneModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }else if ([type isEqualToString:@"images-three-left-two"]){
            Images_three_left_twoModel *model=[[Images_three_left_twoModel alloc] initWithDictionary:moduleJson.json];
            [_modulesArray addObject:model];
            
        }
    }
}
@end
